using System.Collections;
using UnityEngine;

public class BG_Roket : MonoBehaviour
{
	public Transform tf;

	private float rnd;

	public ParticleSystem ps;

	public int startTime;

	private void Start()
	{
		Init();
		StartCoroutine(Move());
	}

	private void Init()
	{
		tf.localPosition = new Vector2(Random.Range(-17f, 8f), -3f);
		rnd = Random.Range(0.1f, 0.2f);
		tf.localScale = new Vector3(rnd, rnd, 1f);
	}

	private IEnumerator Move()
	{
		yield return new WaitForSeconds(startTime);
		while (true)
		{
			tf.localPosition += new Vector3(0f, 0.01f * rnd * 10f);
			if (tf.localPosition.y > tf.localScale.x * 40f + 22f)
			{
				yield return new WaitForSeconds(Random.Range(0f, 3f));
				Init();
			}
			yield return new WaitForFixedUpdate();
		}
	}
}
